![]() | Knowledge Module Syntax | Making references to properties/methods | ![]() |
Knowledge Builder scripting enable procedural statements - assignments, calculations, conditional jumps etc. to be embedded within the logic of your application. It also enables runtime integration with other applications such as ODBC, Object Linking & Embedding (OLE) and Dynamic Link Libraries (DLL's) to be used. Scripting can be used in a variety of ways:
Procedure type Knowledge Explorer objects are specifically for use with XpertRule script, JavaScript or VBScript. They can be used to instigate a procedural command sequence by placing the procedure in the flow of the logic of your application wherever needed. For instance, when inserted into the path of a decision tree. Procedures can also be invoked from a Macro button on a Graphical dialog.
Events are provided as a sub unit of most Knowledge Explorer objects. For example, a List type attribute or a Numeric attribute each have their own set of events. There are several Event windows for each object - such as OnCapture, OnLeave and OnUpdate. The mechanics of editing and using the scripting language are just the same as for Procedures. The difference is that Events are intrinsically tied (i.e. belong solely) to their own object and are executed when the object is encountered by the inference process. The actual timing of the event depends upon your use of the OnCapture, OnLeave and OnUpdate windows.
Note that you can also use Events to invoke Procedures. Within an Event you can use the standard @DO <procedure_name> command to call a procedure. This technique is handy when you have several Events that could use some common code, and you don't want to repeat the code within each Event.
Scripting can utilise any variables available within your application. 'Variables' here mean attributes (of any type), and arrays, as well as numeric and string variables. All such variables can be processed by the commands and can be embedded within reports.
As an alternative to using XpertRule Scripting, you can also use JavaScript or VBScript syntax commands (depending on the deployment type). These are recommended when large sequences of commands are needed in one procedure and the maximum execution speed at run time is required.
Another alternative is to 'tie' a procedure object to a specific attribute, this has advantages and disadvantages:
Procedures that are tied to values or outcomes will be executed whenever the value or outcome is used in a decision tree. This is quick and easy if you always want the script to fire in such a direct one to one relationship. However, inserting Procedures as individual objects on decision trees (not tied to anything) does help to separate 'logic' from 'procedural processing' much better. While not essential, it can make applications easier to understand. Individual Procedure objects also appear on decision trees as visible and quickly edited objects, whereas a tied procedure is not as immediately accessible and less 'visible'.
Using the @Do command, procedures can also call other procedures or graphical dialogs from within.
Procedures are terminated when the end of the script sequence is reached. However, the @Exit command can also be used to terminate a procedure prior to this point.
On the decision tree editors, this small 'micon' will appear after the name of any attribute, value, etc., that has a tied procedure. See the section on Using tied objects.
See also these sections:
How to edit scripts
Inference and scripting
List of XpertRule scripting commands
List of JavaScript commands
Visual Basic Script
List of VBScript commands
Making references to properties/methods
Additional properties accessible via code